function siteGrid=createSiteGrid(sites)

siteGrid.minX=min(sites(:,1));
siteGrid.maxX=max(sites(:,1));
siteGrid.minY=min(sites(:,2));
siteGrid.maxY=max(sites(:,2));
numSites=size(sites,1);

siteGrid.intervalX=(siteGrid.maxX-siteGrid.minX)/sqrt(numSites);
siteGrid.intervalY=(siteGrid.maxY-siteGrid.minY)/sqrt(numSites);

siteGrid.numX=round((siteGrid.maxX-siteGrid.minX)/siteGrid.intervalX);
siteGrid.numY=round((siteGrid.maxY-siteGrid.minY)/siteGrid.intervalY);

siteGrid.grid=cell(siteGrid.numX, siteGrid.numY);
numSites=size(sites,1);
for s=1:numSites
    [x_idx, y_idx]=findIdx(sites(s,1), sites(s,2), siteGrid);
    siteGrid.grid{x_idx, y_idx}=[siteGrid.grid{x_idx, y_idx}, s];
end


